package com.example.demo1.config;

import com.example.demo1.test.Sender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author sunjk
 * @since 2020/9/3
 */
@Component
@EnableScheduling
public class TaskSchedule {

    @Autowired
    private Sender sender;

    @Scheduled(cron = "0/5 * * * * ?")
    public void task() {
        System.out.println("定时任务5秒执行一次");
        sender.send2();
        sender.send3();
    }
}
